package java_util.coo_util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class C_String {
    public final static char e_split01 = '‡';
    public final static char e_split02 = '➜';
    public final static char e_split03 = '✪';
    public final static char e_split04 = '┃';
    public final static char e_split05 = '⊙';
    public final static char e_split06 = '◉';
    public final static char e_split07 = '█';
    public final static char e_split08 = '◆';
    public final static char e_split09 = '▲';
    public final static char e_split10 = '▼';
    public final static char e_split11 = '✖';

    //设置Log颜色字段
    public static String S_SetLogColor(String log, String colorText) {
        //return string.Format("<font size='{0}' color='#{1}'>{2}</font>", fontSize, colorText, ss);//<size=50>www</size>  
        return String.format("#{0}#{1}", colorText, log);
    }

    //获取log颜色字段
    public static String[] S_GetLogColor(String log) {
        String[] sss = new String[2];
        if (log != null && log.length() > 8 && log.charAt(0) == '#' && log.charAt(7) == '#') {
            sss[0] = log.substring(1, 6);
            sss[1] = log.substring(8);
        } else {
            sss[0] = null;
            sss[1] = log;
        }
        return sss;
    }


//    //多字符拆分--------------
//    public static String[] string_split(String content, char[] split, boolean isClearNull) {
//        List<String> list0 = new ArrayList<>();
//        int stratIndex = 0;
//        for (int a = 0; a < content.length(); a++) {
//            boolean isSplit = false;
//            for (int b = 0; b < split.length; b++) {
//                char a0 = content.charAt(a);
//                char b0 = split[b];
//                if (a0 == b0) {
//                    isSplit = true;
//                    break;
//                }
//            }
//            if (a == content.length() - 1) {
//                isSplit = true;
//            }
//            if (isSplit) {
//                String ss = content.substring(stratIndex, a);
//                stratIndex = a + 1;
//                if (isClearNull) {
//                    ss = ss.trim();
//                    if (ss.length() == 0) {
//                        continue;
//                    }
//                }
//                list0.add(ss);
//            }
//        }
//        String[] array = new String[list0.size()];
//        return list0.toArray(array);
//    }

    //多字符串拆分--------------
    public static String[] string0_split(String content, String split, boolean isClearNull) {
        String[] sss = content.split(split);
        if (!isClearNull) {
            return sss;
        }
        List<String> list = new ArrayList<String>();
        for (String s : sss) {
            if (s.equals("")) {
                continue;
            }
            list.add(s);
        }
        return list.toArray(new String[list.size()]);
    }

    public static String[] string_split(String content, String... split_arr) {
        StringBuilder split = new StringBuilder("[" + split_arr[0]);
        for (int i = 1; i < split_arr.length; i++) {
            split.append("|").append(split_arr[i]);
        }
        split.append("]");
        return string0_split(content, split.toString(), true);
    }
    public static String[] string_split(String content, char... split_arr) {
        StringBuilder split = new StringBuilder("[" + split_arr[0]);
        for (int i = 1; i < split_arr.length; i++) {
            split.append("|").append(split_arr[i]);
        }
        split.append("]");
        return string0_split(content, split.toString(), true);
    }

    public static <T> String ToStringLog(T[] tt){
        return null;
    }
    public static <T> String ToStringLog(T[][] tt){
        return null;
    }
    public static <K,V> String ToStringLog(Map<K,V> map){
        return null;
    }
}
